package cn.mymall.service.mall.impl;

import cn.mymall.entity.mall.ShippingRegionPrice;
import cn.mymall.mapper.ShippingRegionPriceMapper;
import cn.mymall.service.mall.IShippingRegionPriceService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.apache.commons.collections.CollectionUtils;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author liqilun
 * @since 2021-07-20
 */
@Service
public class ShippingRegionPriceServiceImpl extends ServiceImpl<ShippingRegionPriceMapper, ShippingRegionPrice> implements IShippingRegionPriceService {
    @Override
    public ShippingRegionPrice findByTemplateIdAndProvincecode(Integer templateId, Integer provinceId) {
        List<ShippingRegionPrice> list = list(new QueryWrapper<ShippingRegionPrice>().eq("template_id", templateId).eq("province_id", provinceId));
        if(CollectionUtils.isEmpty(list)){
            return null;
        }
        return list.get(0);
    }
}
